﻿using System;
using System.Runtime.CompilerServices;
using UnityEngine;

public static class GuidExtension
{
    public static string GetGuid(this Component comp)
    {
        GameObjectGuid componentInParent = comp.GetComponentInParent<GameObjectGuid>();
        if (componentInParent != null)
        {
            return componentInParent.value;
        }
        return null;
    }

    public static string GetGuid(this GameObject go)
    {
        if (go == null)
        {
            return null;
        }
        return go.transform.GetGuid();
    }

    public static bool HasAndEqualsGuid(this Component comp, string guid)
    {
        string str = comp.GetGuid();
        return ((str != null) && (str == guid));
    }
}

